﻿<Window x:Class="SMTP.Test.Client.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cmd="clr-namespace:SMTP.Test.Client.Commands"
        MinHeight="650" MinWidth="850"
        Title="Mail Test Agent (MTA)" Background="#FF656565" >

    <!--Title="SMTP Test Client"   -->
    <Window.Resources>
        <!--Stackpanel Style-->
        <Style TargetType="StackPanel">
            <Setter Property="Margin" Value="0, 5" />
        </Style>

        <!--Title Textblock-->
        <Style TargetType="TextBlock" x:Key="TextTitleBase">
            <Setter Property="FontSize" Value="16" />
            <Setter Property="TextDecorations" Value="Underline" />
            <Setter Property="Margin" Value="0,0,0,15" />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>

        <!--TextBlock Styling-->
        <Style TargetType="TextBlock" x:Key="TextBlockBase">
            <Setter Property="FontSize" Value="14" />
            <Setter Property="TextAlignment" Value="Right" />
            <Setter Property="Width" Value="65" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        
        <!--Textblock attachments-->
        <Style TargetType="TextBlock" x:Key="TextBlockBaseAttachments">
            <Setter Property="FontSize" Value="14" />
            <Setter Property="TextAlignment" Value="Left" />
            <Setter Property="Width" Value="75" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>

        <Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}" x:Key="AttachmentStyle">
            <Setter Property="IsReadOnly" Value="True" />
            <Setter Property="Width" Value="370" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>

        <!--Inherit from ExpressionDark.xaml-->
        <!--TextBox Styling-->
        <Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
            <Setter Property="Width" Value="300" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Margin" Value="10,0" />
        </Style>
        
        <!--Password Textbox Styling-->
        <Style BasedOn="{StaticResource {x:Type PasswordBox}}" TargetType="{x:Type PasswordBox}">
            <Setter Property="Width" Value="300" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Margin" Value="10,0" />
            <Setter Property="PasswordChar" Value="*" />
        </Style>
        
        <!--Email Message Textbox -->
        <Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}" x:Key="MailMessage">
            <Setter Property="Width" Value="370" />
            <Setter Property="Height" Value="150" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Margin" Value="15,0,0,0" />
            <Setter Property="AcceptsReturn" Value="True" />
            <Setter Property="AcceptsTab" Value="True" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="TextWrapping" Value="Wrap" />
        </Style>

        <!--Button Styling-->
        <Style BasedOn="{StaticResource {x:Type Button}}" TargetType="{x:Type Button}">
            <Setter Property="Width" Value="77" />
            <Setter Property="Height" Value="23" />
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Margin" Value="10,0,0,0" />
        </Style>

        <!--Logging textbox-->
        <Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}" x:Key="TextLoggingBase">
            <Setter Property="MinWidth" Value="420" />
            <Setter Property="Width" Value="Auto" />
            <Setter Property="Height" Value="520" />
            <Setter Property="Margin" Value="0" />
            <Setter Property="AcceptsReturn" Value="True" />
            <Setter Property="AcceptsTab" Value="True" />
            <Setter Property="TextWrapping" Value="{Binding WrapLoggingText, Mode=OneWay}" />
            <Setter Property="HorizontalScrollBarVisibility" Value="Visible" />
            <Setter Property="VerticalScrollBarVisibility" Value="Visible" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
        </Style>
    </Window.Resources>

    <Grid Margin="0,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <!--sending emails-->
            <ColumnDefinition Width="*" />
            <!--logging-->
        </Grid.ColumnDefinitions>
        
        <!--Left hand column used to send emails-->
        <StackPanel Margin="5" HorizontalAlignment="Center">
            <!--Title-->
            <TextBlock Text="Email Configuration" Style="{StaticResource ResourceKey=TextTitleBase}" />
            <!--Server & Port No-->
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Server:" Style="{StaticResource ResourceKey=TextBlockBase}" />
                <TextBox x:Name="TextServer" Width="175" Text="{Binding Server, Mode=TwoWay}" />
                <TextBlock Text="Port:" Style="{StaticResource ResourceKey=TextBlockBase}" />
                <TextBox x:Name="TextPort"  Width="50" TextAlignment="Center" Text="{Binding Port, Mode=TwoWay}" />
            </StackPanel>

            <!--To-->
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="To:" Style="{StaticResource ResourceKey=TextBlockBase}" />
                <TextBox x:Name="TextTo" ToolTip="Separate with semi-colon for multiple recipients" Text="{Binding To, Mode=TwoWay}" />
            </StackPanel>

            <!-- From -->
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="From:" Style="{StaticResource ResourceKey=TextBlockBase}" />
                <TextBox x:Name="TextFrom" Text="{Binding From, Mode=TwoWay}" />
            </StackPanel>

            <!-- Subject -->
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Subject:" Style="{StaticResource ResourceKey=TextBlockBase}" />
                <TextBox x:Name="TextSubject" Text="{Binding Subject, Mode=TwoWay}" />
            </StackPanel>

            <!--SSL Option & User/Pass-->
            <Expander Header="SSL &amp; User/Pass Options">
                <StackPanel>
                    <CheckBox Content="Send Credentials" HorizontalAlignment="Right" Margin="0,0,8,25" IsChecked="{Binding SendCredentials, Mode=TwoWay}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Username:" Style="{StaticResource ResourceKey=TextBlockBase}" Foreground="Black" />
                        <TextBox Text="{Binding Username, Mode=TwoWay}" IsEnabled="{Binding SendCredentials, Mode=OneWay}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Password:" Style="{StaticResource ResourceKey=TextBlockBase}" Foreground="Black" />
                        <!--Passwordbox doesn't have a dependency property for Password so we will have to do it the old fashion way-->
                        <PasswordBox x:Name="UserPassword" IsEnabled="{Binding SendCredentials, Mode=OneWay}" />
                    </StackPanel>
                    <CheckBox Content="Use SSL" HorizontalAlignment="Right" Margin="0,0,15,0" IsEnabled="{Binding SendCredentials, Mode=OneWay}" IsChecked="{Binding SendSSL, Mode=TwoWay}" />
                </StackPanel>
            </Expander>
            
            <!--Body-->
            <TextBlock Text="Body:" Style="{StaticResource ResourceKey=TextBlockBase}" HorizontalAlignment="Left" />
            <TextBox x:Name="TextBody" Text="{Binding Body, Mode=TwoWay}" Style="{StaticResource ResourceKey=MailMessage}" />
            
            <!--Attachment-->
            <StackPanel Orientation="Vertical" Margin="15,10">
                <TextBlock Text="Attachment:" Style="{StaticResource ResourceKey=TextBlockBaseAttachments}" />
                <TextBox x:Name="TextAttachment" ToolTip="Separate with semi-colon for multiple recipients" Style="{StaticResource ResourceKey=AttachmentStyle}" Text="{Binding Attachment, Mode=TwoWay}" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.AddAttachment" />
                    <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.ClearAttachment" />
                </StackPanel>
            </StackPanel>
            
            <!--ping host-->
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.SendEmail" Margin="5,0,0,0"  />
                <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.ScanPort"  />
                <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.CancelRequest"  />
                <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.SaveDefaults"  />
            </StackPanel>
            
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <ComboBox x:Name="ComboPingCommands" Width="135" Text="Ping Options" IsEditable="True" IsReadOnly="True" Margin="10,0,0,0" IsDropDownOpen="{Binding PingDropDownIsOpen, Mode=TwoWay}" HorizontalContentAlignment="Center">
                    <ComboBox.Items>
                        <Button Command="cmd:InterfaceCommands.PingHost" Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Margin="0,0,5,0" Width="105" />
                        <Button Command="cmd:InterfaceCommands.PingHostForever" Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Margin="0,0,5,0" Width="105" />
                    </ComboBox.Items>
                </ComboBox>


                <ComboBox x:Name="ComboDNSCommands" Width="135" Text="DNS Options" IsEditable="True" IsReadOnly="True" Margin="10,0,0,0" IsDropDownOpen="{Binding DNSDropDownIsOpen, Mode=TwoWay}" HorizontalContentAlignment="Center">
                    <ComboBox.Items>
                        <Button Command="cmd:InterfaceCommands.DNS_ARecords" Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Margin="0,0,5,0" Width="105" />
                        <Button Command="cmd:InterfaceCommands.DNS_CNAMERecords" Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Margin="0,0,5,0" Width="105" />
                        <Button Command="cmd:InterfaceCommands.DNS_MXRecords" Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}"  Margin="0,0,5,0" Width="105" />
                    </ComboBox.Items>
                </ComboBox>
            </StackPanel>
        </StackPanel>

        <!--logging mechanism-->
        <!--<StackPanel HorizontalAlignment="Center" Grid.Column="1" >-->
        <DockPanel Grid.Column="1" Margin="5,5,5,0" Height="Auto">
            <StackPanel Margin="0,0,15,0">
                <!--Title-->
                <TextBlock Text="Email Logging" Style="{StaticResource ResourceKey=TextTitleBase}" DockPanel.Dock="Top" />

                <!--Logging textbox-->
                <CheckBox Content="Wrap Text" IsChecked="{Binding WrapText, Mode=TwoWay}" HorizontalAlignment="Right" Margin="0,-15,5,2" DockPanel.Dock="Top" />
                <TextBox x:Name="TextLog" Text="{Binding SessionLog, Mode=OneWay}" TextWrapping="{Binding WrapType, Mode=OneWay}"  Style="{StaticResource ResourceKey=TextLoggingBase}" TextChanged="TextLog_TextChanged" IsReadOnly="{Binding RunningRequest, Mode=OneWay}" DockPanel.Dock="Bottom" />
 
                <!--Save & Clear Buttons-->
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Stretch" DockPanel.Dock="Bottom">
                    <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="Save" />
                    <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" Command="cmd:InterfaceCommands.ClearLog" />
                </StackPanel>
            </StackPanel>
        </DockPanel>
    </Grid>
</Window>
